/**
 * 运动员变更管理API接口
 */
import { http } from '@/utils/request'
import type {
	ChangeQueryParams,
	ChangeListResponse,
	ChangeApprovalParams,
	CommonResponse,
	ProjectChangeInfo,
	OrgChangeInfo
} from './types'

// 使用运动员API的前缀
const prefix = import.meta.env.VITE_API_ATHLETE

/**
 * 获取变更列表
 * @param params 查询参数
 * @returns 变更列表响应
 */
export const getChangeListApi = (params: ChangeQueryParams): Promise<ChangeListResponse> => {
	return http.get(`${prefix}/change/list`, params)
}

/**
 * 获取变更详情
 * @param id 变更ID
 * @returns 变更详情响应
 */
export const getChangeDetailApi = (id: string | number): Promise<CommonResponse> => {
	return http.get(`${prefix}/change/${id}`)
}

/**
 * 批量审批变更申请
 * @param params 审批参数
 * @returns 审批结果响应
 */
export const batchApprovalChangeApi = (params: ChangeApprovalParams): Promise<CommonResponse> => {
	return http.post(`${prefix}/change/batchApproval`, params)
}

/**
 * 单个审批变更申请
 * @param id 变更ID
 * @param params 审批参数
 * @returns 审批结果响应
 */
export const approvalChangeApi = (id: string | number, params: Omit<ChangeApprovalParams, 'ids'>): Promise<CommonResponse> => {
	return http.post(`${prefix}/change/${id}/approval`, params)
}

/**
 * 一键审批所有待处理变更申请
 * @param params 审批参数
 * @returns 审批结果响应
 */
export const batchApprovalAllPendingApi = (params: Omit<ChangeApprovalParams, 'ids'>): Promise<CommonResponse> => {
	return http.post(`${prefix}/change/batchApprovalAllPending`, params)
}
